/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaclientcp3110.View.Component;

import javaclientcp3110.Model.MainModel;
import common.Objects.Component;
import java.util.Vector;
import javax.swing.JComboBox;

/**
 * 
 * @author Richard Irons
 */
public class ComponentListView extends JComboBox {

    public ComponentListView() {
    }

    /**
     * Populates the combobox with components that match those from a certain
     * category.
     * @param categoryId - Category that the items will be listed by
     */
    public void populateComboBox_viaCategory(int categoryId) {
        removeAllItems();
        addItem(new Component());
        for (Component component : MainModel.getInstance().getComponents()) {
            if (component.getCategoryId() == categoryId) {
                addItem(component);
            }
        }
    }
    public Vector<Component> getObjects_Components () {
        Vector<Component> tempComp = new Vector<Component>();
        for (int i = 0;i < this.getItemCount();i++) {
            tempComp.add((Component)getItemAt(i));
        }
        return tempComp;
    }
}
